<?php
	if(isset($_GET['id']) && isset($_GET['pin']))
	{
		$MaGiaoVien = trim($_GET['id']);
		$PIN        = trim($_GET['pin']);
		include_once '../classes/giaovien_bs.php';
		
		$GiaoVien = new giaovien_bs();
		$GiaoVien->SetMaGiaoVien($MaGiaoVien);
		$DGiaoVien = $GiaoVien->LayDanhSach();
		if($DGiaoVien == null)
			header('Location: index.php?act=giaovien_danhsach');
		elseif(trim($DGiaoVien[0]['PIN']) == $PIN)
		{
?>
	<div class="FormCapNhat">
		<form action="index.php?act=hocvien_capnhat_sub" method="POST">
			<div class="Title">
				Thông tin chi tiết giáo viên - <?php echo $DGiaoVien[0]['MaGiaoVien']; ?>
				<div style="float:right">
					<a href="index.php?act=giaovien_capnhat&id=<?php echo $MaGiaoVien; ?>&pin=<?php echo $PIN; ?>">Cập nhật</a>
				</div>
			</div>
			
			<div class="Left">
				<table width="100%">
					<tr>
						<th colspan="2">Thông tin cá nhân</th>
					</tr>
					<tr>
						<td width="20%">Mã giáo viên</td>
						<td><input name="MaHocVien" type="text" readonly="true" value="<?php echo $DGiaoVien[0]['MaGiaoVien']; ?>"/></td>
					</tr>
					<tr>
						<td>Họ tên</td>
						<td><input readonly="true" name="HoTen" style="font-weight:bold" type="text" value="<?php echo $DGiaoVien[0]['HoTen']; ?>"/></td>
					</tr>
					<tr>
						<td>Ngày sinh</td>
						<td><input readonly="true" type="text" value="<?php echo ConvertDate($DGiaoVien[0]['NgaySinh']); ?>"/></td>
					</tr>
					<tr>
						<td>Giới tính</td>
						<td>
							<input disabled="true" type="radio" id="radioNam" name="GioiTinh" class="css-radio" <?php echo ($DGiaoVien[0]['GioiTinh'] == 0 ? 'checked="checked"' : '');?>/>
							<label for="radioNam" class="css-labelRadio">Nam</label>
							<input disabled="true" type="radio" id="radioNu" name="GioiTinh" class="css-radio" <?php echo ($DGiaoVien[0]['GioiTinh'] == 1 ? 'checked="checked"' : '');?>/>
							<label for="radioNu" class="css-labelRadio">Nữ</label>
						</td>
					</tr>
					<tr>
						<td>Địa chỉ</td>
						<td><input readonly="true" name="DiaChi" type="text" value="<?php echo $DGiaoVien[0]['DiaChi']; ?>"/></td>
					</tr>
					<tr>
						<td>Điện thoại</td>
						<td><input readonly="true" name="DienThoai" type="text" value="<?php echo $DGiaoVien[0]['DienThoai']; ?>"/></td>
					</tr>
					<tr>
						<td>Email</td>
						<td><input readonly="true" name="Email" type="text" value="<?php echo $DGiaoVien[0]['Email']; ?>"/></td>
					</tr>
				</table>
			</div>
			<div class="Right">
				<table width="100%">
					<tr>
						<th colspan="2">CICT</th>
					</tr>
					<tr>
						<td width="35%">Chức vụ</td>
						<td>
							<?php
								include_once '../classes/chucvu_bs.php';
								$ChucVu = new chucvu_bs();
								$ChucVu->SetMaChucVu($DGiaoVien[0]['MaChucVu']);
								$DChucVu = $ChucVu->LayDanhSach();
								$TCV = $DChucVu == null ? '-' : $DChucVu[0]['TenChucVu'];
							?>
							<input type="text" readonly="true" value="<?php echo $TCV; ?>" />
						</td>
					</tr>
					<tr>
						<td>Số H.Đồng đã ký</td>
						<td>
							<?php
								include_once '../classes/hopdong_bs.php';
								$HopDong = new hopdong_bs();
								$HopDong->SetMaGiaoVien($DGiaoVien[0]['MaGiaoVien']);
								$DHopDong = $HopDong->LayDanhSach();
								$SHD = $DHopDong == null ? 0 : count($DHopDong);
							?>
							<input type="text" readonly="true" value="<?php echo $SHD; ?>"/>
						</td>
					</tr>
					<tr>
						<td>H.Đồng gần nhất</td>
						<td>
							<?php
								$HDGN = $DHopDong == null ? '-' : $DHopDong[0]['MaLopHoc'];
							?>
							<input readonly="true" name="SoMay" type="text" value="<?php echo $HDGN; ?>" />
						</td>
					</tr>
					<tr>
						<td>H.Đồng đầu tiên</td>
						<td>
							<?php
								$HDDT = $DHopDong == null ? '-' : $DHopDong[count($DHopDong) - 1]['MaLopHoc'];
							?>
							<input readonly="true" name="SoMay" type="text" value="<?php echo $HDDT; ?>" />
						</td>
					</tr>
				</table>
				
			</div>
			
			<div class="Bottom">
				<a href="index.php?act=giaovien_danhsach" class="LinkBackToList">Danh sách giáo viên</a>
			</div>
		</form>
	</div>
<?php
		}
		else
			header('Location: index.php?act=giaovien_danhsach');
	}
	else
	{
		header('Location: index.php?act=giaovien_danhsach');
	}